#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//复习lambda表达式，掌握用法和使用场景

void test(){
    //值捕获 
    int num=10;
    [num](int x){return x+10;}(num);
    cout<<num<<endl;
    //引用捕获
    [&](int x){return ++x;}(num);
    cout<<num<<endl;
}
void test1(){
    int number=1;
    [&](int value){
        ++value;
        cout<<"value="<<value<<endl;
        ++number;
        cout<<"number="<<number<<endl;
    }(100);
}
void test2(){
    auto func=[](){cout<<"hello"<<endl;};
    func();
}
void test3(){
    vector<int> vec={1,2,3,4,5,6};
    auto count=count_if(vec.begin(),vec.end(),[](int x){return x>4;});
    cout<<count<<endl;    
}
int main(int argc, char * argv[]){
    test3();
    return 0;
}

